package cc.lj.internal.coupons.interfaces.facade;

import cc.lj.internal.core.exception.SysExceptionEnum;
import cc.lj.internal.core.http.HttpResult;
import cc.lj.internal.coupons.application.service.DeleteUseTicketCheckAppService;
import cc.lj.internal.coupons.application.service.UseTicketCheckAppService;
import cc.lj.internal.coupons.interfaces.dto.TicketMainDTO;
import cc.lj.internal.coupons.interfaces.dto.command.DeleteUseTicketCheckCommand;
import cc.lj.internal.coupons.interfaces.dto.command.UseTicketCheckCommand;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * 取消用券验证规则
 * @author liangxifeng
 * @date 2022-06-14
 */
@RestController
@Slf4j
@Validated
@Api(tags = "取消用券验证规则接口")
@RequestMapping("deleteUseTicket")
public class DeleteUseTicketCheckController {
    @Autowired
    private DeleteUseTicketCheckAppService deleteUseTicketCheckAppService;

    /**
     * 取消用券验证规则
     * 成功返回：成功删除的券使用码list
     * 验证失败返回DTO=NULL
     */
    @PostMapping("/checkRule")
    public HttpResult<List<String>> checkRule(@Valid @RequestBody DeleteUseTicketCheckCommand command) {
        List<String> res = deleteUseTicketCheckAppService.doMain(command);
        return HttpResult.success(SysExceptionEnum.SUCCESS.getCode(),SysExceptionEnum.SUCCESS.getMessage(),res);
    }
}
